package com.example.wacoffee_manage.task;

import com.example.wacoffee_manage.Mapper.OrderMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
@Slf4j
public class OrderTask {

    @Autowired
    private OrderMapper orderMapper;
    @Scheduled(cron ="0 0/1 * * * ? ")
    public void processTimeoutOrCancelOrder(){
        log.info("处理超时订单:{}", LocalDateTime.now());
        LocalDateTime standard= LocalDateTime.now().minusMinutes(15);
        Integer[] ids=orderMapper.getProcessTimeoutOrderIds(standard);
        orderMapper.processTimeoutOrder(standard);
        orderMapper.processTimeoutOrderInOrderGood(ids);
    }


}
